How to: Create a Calculated control in a report.
Solution:
In the Report Design view, click 'Text Box' from the Toolbox. Type the expression either directly into the text box or by using the text box property sheet.
1) If the Database window is not active, activate the Database window.
2) Click the 'Reports' tab in the Database window.
Reports tab
3) Select the desired report from the list box. (The selected report is highlighted.)
4) Click 'Design'. (The selected report appears in the Design view, and the floating Toolbox appears.)
5) Make sure the 'Control Wizard' button located in the 'Toolbox' is depressed.
Control Wizard and Text Box
6) Click 'Text Box' from the Toolbox.
7) Click the desired location for the 'Text Box' in the report. (Both the label and the text box appear on the report.)
Label box and text box.
8) Do one of the following:
a) Single-click in the text box and type the expression.
Type Expression
NOTE: The expression refers to at least one field from the table or query to which the report is related. When referring to the field, enclose the field name with '[' and ']' and begin the expression with the '=' operator.
Type Expression
b) Do the following to set properties for the control:
1] Single-click on the 'Text Box'. (Handles appear around the box.)
Handles around the text box
2] Select the 'View' menu and 'Properties'. (The property sheet appears.)
3] Click the 'Data' tab.
Properties button and property sheet
4] Click in the 'Control Source' property box. (A drop-down list appears.)
5] Select the field(s) to be used in the expression.
Data Tab and drop-down list
NOTE: Separate each field with an operator.
6] Build the expression using the desired operators in the 'Control Source' property box.
NOTE: Integers can be used as part of the expression.
EXAMPLE: =<[Unitprice]>*5
(where <[Unitprice]> is a field from the selected table or query that is to be multiplied by 5).
Control Source property box
7] To close the property sheet, click 'X' in the upper-right hand corner of the property sheet.
Click the X button to close property sheet
NOTE: The properties will be saved only when the design view is saved.
9) To edit the label box, do the following:
a) Select the label box. (Handles appear around the box.)
b) Select the 'View' menu and select 'Properties'. (The property sheet appears.)
c) Select the 'Format' tab.
d) Type the name of the label box in the 'Caption' property box.
Editing the label box
e) To close the property sheet, click 'X' in the upper-right hand corner of the property sheet.
Click the X button to close property sheet
NOTE: The properties will be saved only when the design view is saved.